package com.sc.nft.service.impl;

import com.google.common.collect.Lists;
import com.sc.nft.dao.PushRecordDao;
import com.sc.nft.entity.PushRecord;
import com.sc.nft.entity.vo.FavoriteApeVO;
import com.sc.nft.entity.vo.HouseOfTibetansVO;
import com.sc.nft.enums.PushTypeEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.service.PushRecordService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 服务接口实现
 *
 * @author Sun
 * @since 2022-09-06 14:27:28
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class PushRecordServiceImpl implements PushRecordService {
    private final PushRecordDao pushRecordDao;

    @Override
    public ArrayList<HouseOfTibetansVO> getHouseOfTibetansList() {
        List<PushRecord> listByType = pushRecordDao.getListByType(PushTypeEnum.HOUSE_OF_TIBETANS);
        ArrayList<HouseOfTibetansVO> list = Lists.newArrayList();
        for (PushRecord pushRecord : listByType) {
            HouseOfTibetansVO houseOfTibetansVO = new HouseOfTibetansVO();
            houseOfTibetansVO.setNftId(pushRecord.getProductUuid());
            houseOfTibetansVO.setNftName(pushRecord.getFirstTitle());
            houseOfTibetansVO.setImage(pushRecord.getCreationContent());
            houseOfTibetansVO.setPublishPrice(pushRecord.getProductNum());
            houseOfTibetansVO.setPublishCount(pushRecord.getCount());
            houseOfTibetansVO.setSellDate(pushRecord.getBeginTime());
            list.add(houseOfTibetansVO);

        }
        return list;
    }

    @Override
    public ArrayList<FavoriteApeVO> getFavoriteApeList() {
        List<PushRecord> listByType = pushRecordDao.getListByType(PushTypeEnum.FAVORITE_APE);
        ArrayList<FavoriteApeVO> list = Lists.newArrayList();
        for (PushRecord pushRecord : listByType) {
            FavoriteApeVO favoriteApeVO = new FavoriteApeVO();
            favoriteApeVO.setName(pushRecord.getFirstTitle());
            favoriteApeVO.setIcon(pushRecord.getCreationContent());
            favoriteApeVO.setPrice(pushRecord.getProductNum());
            favoriteApeVO.setCount(pushRecord.getCount());
            favoriteApeVO.setDate(pushRecord.getBeginTime());
            list.add(favoriteApeVO);
        }
        return list;
    }
}